package com.example.demo.configuration

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import springfox.documentation.builders.ApiInfoBuilder
import springfox.documentation.builders.PathSelectors
import springfox.documentation.builders.RequestHandlerSelectors
import springfox.documentation.service.ApiInfo
import springfox.documentation.spi.DocumentationType
import springfox.documentation.spring.web.plugins.Docket

/**
 * Created with IntelliJ IDEA.
 * Author:流年的樱花逝
 * Date:2018/11/14
 * Time:10:23
 */
@Configuration
class Swagger2 {
    @Bean
    fun createRestApi(): Docket {
        return Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.demo.controller"))
                .paths(PathSelectors.any())
                .build()
    }

    fun apiInfo(): ApiInfo {
        return ApiInfoBuilder()
                .title("小程序后台")
                .description("swagger2构建的")
                .termsOfServiceUrl("https://www.bdth.com/api/swagger-ui.html")
                .version("1.0")
                .build()
    }
}